package com.yangj.manager;

import com.yangj.service.*;
import com.yangj.util.*;
import org.junit.*;

public class TemplateMessageManager
{
    @Test
    /*
     * 设置行业信息
     * */
    public void set() {
        final String at = WeChatVerifyService.getAccessToken();
        final String url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=" + at;
        final String data = "{\"industry_id1\":\"1\",\"industry_id2\":\"2\"}";
        final String result = MyUtils.post(url, data);
        System.out.println(result);
    }
    
    @Test
    /*
     * 获取行业信息
     * */
    public void get() {
        final String at = WeChatVerifyService.getAccessToken();
        final String url = "https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=" + at;
        final String result = MyUtils.get(url);
        System.out.println(result);
    }
    
    @Test
    /*
     * 设置模板消息
     * */
    public void sendTemplateMessage(){
		String at = WeChatVerifyService.getAccessToken();
		String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" +at;
		String data =" { " 
          + "\"touser\":\"oUIvD5pf3Lyit3Gb9fGVtwuvRCzM\","
          + "\"template_id\":\"TbnZCASAw67I4cbBhyWd0HcPFOql0_k6s9dbr1hLBOo\","          
          + "\"data\":{"
          +         "\"first\": {"
          +             "\"value\":\"您好，有待办事件需处理如下\","
          +             "\"color\":\"#173177\""
          +         "},"
          +         "\"keyword1\": {"
          +             "\"value\":\"微信公众号开发计划\","
          +            "\"color\":\"#173177\""
          +         "},"
          +        "\"keyword2\":{"
          +             "\"value\":\"2021年3月1日\","
          +            "\"color\":\"#173177\""
          +        " },"
          +         "\"keyword3\": {"
          +            "\"value\":\"北京海淀区\","
          +            "\"color\":\"#173177\""
          +         "},"         
          +         "\"remark\":{"
          +            "\"value\":\"记得开始哦，宝贝!\","
          +             "\"color\":\"#173177\""
          +        "}"
          +"}"
          +"}";
		System.out.println("data: "+ data);
		String result = MyUtils.post(url, data);
    }
}
